﻿using DevExpress.XtraGrid.Views.Base;

namespace Lonntec.DevClient
{
    using DevExpress.XtraEditors;
    using DevExpress.XtraEditors.Controls;
    using DevExpress.XtraEditors.Repository;
    using DevExpress.XtraGrid;
    using DevExpress.XtraGrid.Columns;
    using DevExpress.XtraGrid.Views.Grid;
    using Furious.Data;
    using Lonntec.UI;
    using System;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Windows.Forms;

    public class SqlScriptForm : DocumentBase
    {
        private GridColumn colFDescription;
        private GridColumn colFKey;
        private GridColumn colFScript;
        private IContainer components;
        private SmartColumn dsColumnFDescription;
        private SmartColumn dsColumnFKey;
        private SmartColumn dsColumnFRowID;
        private SmartColumn dsColumnFScript;
        private SmartColumn dsColumnFVersionID;
        private SmartSource dsMaster;
        private GridControl gridMaster;
        private GridView gvMaster;
        private LabelControl labelControl1;
        private LabelControl labelControl2;
        private LabelControl labelControl3;
        private MemoEdit memoEdit1;
        private RepositoryItemMemoEdit repositoryItemMemoEdit1;
        private RepositoryItemMemoExEdit repositoryItemMemoExEdit1;
        private TextEdit textEdit1;
        private TextEdit textEdit2;

        public SqlScriptForm()
        {
            this.InitializeComponent();
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing && (this.components != null))
            {
                this.components.Dispose();
            }
            base.Dispose(disposing);
        }

        private void InitializeComponent()
        {
            this.dsMaster = new SmartSource();
            this.dsColumnFRowID = new SmartColumn();
            this.dsColumnFKey = new SmartColumn();
            this.dsColumnFScript = new SmartColumn();
            this.dsColumnFDescription = new SmartColumn();
            this.dsColumnFVersionID = new SmartColumn();
            this.gridMaster = new GridControl();
            this.gvMaster = new GridView();
            this.colFKey = new GridColumn();
            this.colFDescription = new GridColumn();
            this.colFScript = new GridColumn();
            this.repositoryItemMemoExEdit1 = new RepositoryItemMemoExEdit();
            this.labelControl1 = new LabelControl();
            this.textEdit1 = new TextEdit();
            this.labelControl2 = new LabelControl();
            this.memoEdit1 = new MemoEdit();
            this.textEdit2 = new TextEdit();
            this.labelControl3 = new LabelControl();
            this.repositoryItemMemoEdit1 = new RepositoryItemMemoEdit();
            base.plTop.BeginInit();
            base.plTop.SuspendLayout();
            base.TabControl.BeginInit();
            base.TabControl.SuspendLayout();
            base.tabPageGrid.SuspendLayout();
            base.tabPageCard.SuspendLayout();
            base.plCard.BeginInit();
            base.plCard.SuspendLayout();
            base.plGrid.BeginInit();
            base.plGrid.SuspendLayout();
            ((ISupportInitialize) this.dsMaster).BeginInit();
            this.gridMaster.BeginInit();
            this.gvMaster.BeginInit();
            this.repositoryItemMemoExEdit1.BeginInit();
            this.textEdit1.Properties.BeginInit();
            this.memoEdit1.Properties.BeginInit();
            this.textEdit2.Properties.BeginInit();
            this.repositoryItemMemoEdit1.BeginInit();
            base.SuspendLayout();
            base.tabPageCard.Appearance.PageClient.BackColor = Color.White;
            base.tabPageCard.Appearance.PageClient.Options.UseBackColor = true;
            base.plCard.Controls.Add(this.textEdit2);
            base.plCard.Controls.Add(this.labelControl3);
            base.plCard.Controls.Add(this.memoEdit1);
            base.plCard.Controls.Add(this.labelControl2);
            base.plCard.Controls.Add(this.textEdit1);
            base.plCard.Controls.Add(this.labelControl1);
            base.plGrid.Controls.Add(this.gridMaster);
            this.dsMaster.Columns.AddRange(new SmartColumn[] { this.dsColumnFRowID, this.dsColumnFKey, this.dsColumnFScript, this.dsColumnFDescription, this.dsColumnFVersionID });
            this.dsMaster.Key = "dsMaster";
            this.dsMaster.OwnerControl = this;
            this.dsMaster.ParentSource = null;
            this.dsMaster.SourceScript = new SqlScript("SELECT \r\n  FRowID,\r\n  FKey,\r\n  FScript,\r\n  FDescription,\r\n  FVersionID\r\nFROM \r\n  T_Sql_Script", null, null);
            this.dsMaster.TableCaption = "数据库访问脚本";
            this.dsMaster.TableName = "T_Sql_Script";
            this.dsColumnFRowID.FieldAlias = null;
            this.dsColumnFRowID.FieldName = "FRowID";
            this.dsColumnFRowID.FullName = "FRowID";
            this.dsColumnFKey.AllowEmpty = false;
            this.dsColumnFKey.AllowExists = false;
            this.dsColumnFKey.FieldAlias = null;
            this.dsColumnFKey.FieldCaption = "脚本标识";
            this.dsColumnFKey.FieldName = "FKey";
            this.dsColumnFKey.FullName = "FKey";
            this.dsColumnFScript.AllowEmpty = false;
            this.dsColumnFScript.FieldAlias = null;
            this.dsColumnFScript.FieldCaption = "脚本内容";
            this.dsColumnFScript.FieldName = "FScript";
            this.dsColumnFScript.FullName = "FScript";
            this.dsColumnFDescription.FieldAlias = null;
            this.dsColumnFDescription.FieldCaption = "脚本描述";
            this.dsColumnFDescription.FieldName = "FDescription";
            this.dsColumnFDescription.FullName = "FDescription";
            this.dsColumnFVersionID.FieldAlias = null;
            this.dsColumnFVersionID.FieldName = "FVersionID";
            this.dsColumnFVersionID.FullName = "FVersionID";
            this.gridMaster.DataSource = this.dsMaster;
            this.gridMaster.Dock = DockStyle.Fill;
            this.gridMaster.Location = new Point(0, 0);
            this.gridMaster.MainView = this.gvMaster;
            this.gridMaster.Name = "gridMaster";
            this.gridMaster.RepositoryItems.AddRange(new RepositoryItem[] { this.repositoryItemMemoExEdit1, this.repositoryItemMemoEdit1 });
            this.gridMaster.Size = new Size(0x2c9, 0x18d);
            this.gridMaster.TabIndex = 0;
            this.gridMaster.ViewCollection.AddRange(new BaseView[] { this.gvMaster });
            this.gvMaster.Columns.AddRange(new GridColumn[] { this.colFKey, this.colFDescription, this.colFScript });
            this.gvMaster.GridControl = this.gridMaster;
            this.gvMaster.Name = "gvMaster";
            this.gvMaster.OptionsView.ShowGroupPanel = false;
            this.colFKey.FieldName = "FKey";
            this.colFKey.Name = "colFKey";
            this.colFKey.OptionsColumn.ReadOnly = true;
            this.colFKey.Visible = true;
            this.colFKey.VisibleIndex = 0;
            this.colFDescription.FieldName = "FDescription";
            this.colFDescription.Name = "colFDescription";
            this.colFDescription.Visible = true;
            this.colFDescription.VisibleIndex = 1;
            this.colFScript.ColumnEdit = this.repositoryItemMemoEdit1;
            this.colFScript.FieldName = "FScript";
            this.colFScript.Name = "colFScript";
            this.colFScript.Visible = true;
            this.colFScript.VisibleIndex = 2;
            this.repositoryItemMemoExEdit1.AutoHeight = false;
            this.repositoryItemMemoExEdit1.Buttons.AddRange(new EditorButton[] { new EditorButton(ButtonPredefines.Combo) });
            this.repositoryItemMemoExEdit1.Name = "repositoryItemMemoExEdit1";
            this.labelControl1.Location = new Point(20, 0x11);
            this.labelControl1.Name = "labelControl1";
            this.labelControl1.Size = new Size(0x30, 14);
            this.labelControl1.TabIndex = 0;
            this.labelControl1.Text = "脚本标识";
            this.textEdit1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.textEdit1.DataBindings.Add(new Binding("EditValue", this.dsMaster, "FKey", true));
            this.textEdit1.Location = new Point(0x4a, 14);
            this.textEdit1.Name = "textEdit1";
            this.textEdit1.Properties.Appearance.Font = new Font("Consolas", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.textEdit1.Properties.Appearance.Options.UseFont = true;
            this.textEdit1.Size = new Size(0x274, 0x15);
            this.textEdit1.TabIndex = 0;
            this.labelControl2.Location = new Point(20, 0x48);
            this.labelControl2.Name = "labelControl2";
            this.labelControl2.Size = new Size(0x30, 14);
            this.labelControl2.TabIndex = 2;
            this.labelControl2.Text = "脚本内容";
            this.memoEdit1.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Bottom | AnchorStyles.Top;
            this.memoEdit1.DataBindings.Add(new Binding("EditValue", this.dsMaster, "FScript", true));
            this.memoEdit1.Location = new Point(0x4a, 70);
            this.memoEdit1.Name = "memoEdit1";
            this.memoEdit1.Properties.Appearance.Font = new Font("Consolas", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.memoEdit1.Properties.Appearance.Options.UseFont = true;
            this.memoEdit1.Size = new Size(0x274, 0x13c);
            this.memoEdit1.TabIndex = 2;
            this.textEdit2.Anchor = AnchorStyles.Right | AnchorStyles.Left | AnchorStyles.Top;
            this.textEdit2.DataBindings.Add(new Binding("EditValue", this.dsMaster, "FDescription", true));
            this.textEdit2.Location = new Point(0x4a, 0x29);
            this.textEdit2.Name = "textEdit2";
            this.textEdit2.Properties.Appearance.Font = new Font("Consolas", 9f, FontStyle.Regular, GraphicsUnit.Point, 0);
            this.textEdit2.Properties.Appearance.Options.UseFont = true;
            this.textEdit2.Size = new Size(0x274, 0x15);
            this.textEdit2.TabIndex = 1;
            this.labelControl3.Location = new Point(20, 0x2c);
            this.labelControl3.Name = "labelControl3";
            this.labelControl3.Size = new Size(0x30, 14);
            this.labelControl3.TabIndex = 4;
            this.labelControl3.Text = "脚本描述";
            this.repositoryItemMemoEdit1.Name = "repositoryItemMemoEdit1";
            base.AutoScaleDimensions = new SizeF(7f, 14f);
            base.AutoScaleMode = AutoScaleMode.Font;
            base.ClientSize = new Size(0x2cb, 0x1c6);
            base.Name = "SqlScriptForm";
            this.Text = "SqlScriptForm";
            base.plTop.EndInit();
            base.plTop.ResumeLayout(false);
            base.TabControl.EndInit();
            base.TabControl.ResumeLayout(false);
            base.tabPageGrid.ResumeLayout(false);
            base.tabPageCard.ResumeLayout(false);
            base.plCard.EndInit();
            base.plCard.ResumeLayout(false);
            base.plCard.PerformLayout();
            base.plGrid.EndInit();
            base.plGrid.ResumeLayout(false);
            ((ISupportInitialize) this.dsMaster).EndInit();
            this.gridMaster.EndInit();
            this.gvMaster.EndInit();
            this.repositoryItemMemoExEdit1.EndInit();
            this.textEdit1.Properties.EndInit();
            this.memoEdit1.Properties.EndInit();
            this.textEdit2.Properties.EndInit();
            this.repositoryItemMemoEdit1.EndInit();
            base.ResumeLayout(false);
        }

        protected override void OnInitializationDataGrids()
        {
            base.OnInitializationDataGrids();
            base.MasterGridView = this.gvMaster;
        }

        protected override void OnInitializationDataSources()
        {
            base.OnInitializationDataSources();
            base.MasterSource = this.dsMaster;
            base.MasterSource.DbAccess = base.ProxyFactory.ResolveProxy<ISingleDbAccess>();
        }

        public override void OnInitializationRegisterSearchFields()
        {
            base.OnInitializationRegisterSearchFields();
            base.RegisterQuickSearchFields(new string[] { "FKey", "FScript" });
        }

        protected override void OnMasterTableNewRow(object sender, DataTableNewRowEventArgs e)
        {
            base.OnMasterTableNewRow(sender, e);
            e.Row["FRowID"] = Guid.NewGuid();
        }
    }
}

